//
//  MSCustomerRecommenCell.m
//  SocietySale
//
//  Created by Mike on 16/11/30.
//  Copyright © 2016年 Mike. All rights reserved.
//

#import "MSCustomerRecommenCell.h"

@interface MSCustomerRecommenCell ()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *typeLabel;
@property (nonatomic, strong) UILabel *stateLabel;
@property (nonatomic, strong) UIView  *bgView;
@end

@implementation MSCustomerRecommenCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self initView];
    }
    return self;
}

- (void)initView {
    self.titleLabel = [self creatLabel:CGRectMake(12, 10, SCREEN_WIDTH, 20)];
    self.titleLabel.font = HeitiFont(15);
    
    self.typeLabel = [self creatLabel:CGRectMake(12, self.titleLabel.bottom+10, SCREEN_WIDTH, 20)];
    self.stateLabel = [self creatLabel:CGRectMake(12, self.typeLabel.bottom+6, SCREEN_WIDTH, 20)];
    
    _bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 92, SCREEN_WIDTH, 8)];
    _bgView.backgroundColor = kDefaultViewBackgroundColor;
    [self.contentView addSubview:_bgView];
    
    UIView *horizonLineView =[[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 0.6)];
    horizonLineView.backgroundColor = kNormalGray;
    [_bgView addSubview:horizonLineView];
}

//创建label
- (UILabel*)creatLabel:(CGRect)frame{
    UILabel *label = [[UILabel alloc] initWithFrame:frame];
    label.font = HeitiFont(14);
    label.textColor = kDarkGrayColor;
    [self.contentView addSubview:label];
    return label;
}

- (void)setModel:(MSDetailContactModel *)model{
    _model = model;
    
    NSMutableAttributedString *titleAttstr = [[NSMutableAttributedString alloc] initWithString:model.name attributes:@{NSForegroundColorAttributeName:kBlueColor}];
    NSAttributedString *positionStr = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"   %@",model.position]];
    [titleAttstr appendAttributedString:positionStr];
    
    self.titleLabel.attributedText = titleAttstr;
    self.typeLabel.text = model.company;
    self.stateLabel.text = model.source;
}

@end
